<?php
class Event_model extends CI_Model
{	
	function __construct()
	{
		parent::__construct();		
	}
	
	function getEvent($query=FALSE,$id=FALSE,$limit=FALSE,$offset=FALSE){
		if (!$query):
			$this->db->where('id_event',$id);
			return $this->db->get('tk_event')->row();
		elseif($query=='all'):
			$this->db->limit($limit,$offset);
			$this->db->order_by('id_event','desc');
			return $this->db->get('tk_event')->result_array();
		elseif($query=='load'):
			return $this->db->get('tk_event')->result_array();
		endif;
	}

	function getClass($id){
		$this->db->where('id_event',$id);
		return $this->db->get('tk_class')->result_array();	
	}
	
	function addEvent($data){
		$this->db->insert('tk_event',$data);
	}
	
	function addEventClass($data){
		$this->db->insert('tk_class',$data);
	}
	
	function editEventClass($id,$data){
		$this->db->where('id_event',$id);
		$this->db->insert('tk_class',$data);
	}	
	
	function editEvent($id,$data){
		$this->db->where('id_event',$id);
		$this->db->update('tk_event',$data);
	}

	function deleteEvent($id){
		$this->db->where('id_event',$id);
		$this->db->delete('tk_event');
		$this->db->delete('tk_class');		
	}
	
	
}

